package com.zhentao.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 汇总查询结果表：存储汇总查询的结果数据
 * @TableName summary_query_result
 */
@TableName(value ="summary_query_result")
@Data
public class SummaryQueryResult {
    /**
     * 主键ID
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 关联的查询条件ID
     */
    private Long queryConditionId;

    /**
     * 分组维度值（JSON格式，如关区、企业等）
     */
    private String dimensionValues;

    /**
     * 报关单数量
     */
    private Long declareCount;

    /**
     * 记录数量
     */
    private Long recordCount;

    /**
     * 金额（人民币）
     */
    private BigDecimal amountCny;

    /**
     * 金额（美元）
     */
    private BigDecimal amountUsd;

    /**
     * 商品数量
     */
    private Long goodsQuantity;

    /**
     * 其他数值型字段（JSON格式，动态扩展）
     */
    private String numericFields;

    /**
     * 父级结果ID（用于下钻查询的层级关系）
     */
    private Long parentId;

    /**
     * 层级深度（1-第一层，2-第二层，以此类推）
     */
    private Integer level;

    /**
     * 创建时间
     */
    private Date createTime;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        SummaryQueryResult other = (SummaryQueryResult) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getQueryConditionId() == null ? other.getQueryConditionId() == null : this.getQueryConditionId().equals(other.getQueryConditionId()))
            && (this.getDimensionValues() == null ? other.getDimensionValues() == null : this.getDimensionValues().equals(other.getDimensionValues()))
            && (this.getDeclareCount() == null ? other.getDeclareCount() == null : this.getDeclareCount().equals(other.getDeclareCount()))
            && (this.getRecordCount() == null ? other.getRecordCount() == null : this.getRecordCount().equals(other.getRecordCount()))
            && (this.getAmountCny() == null ? other.getAmountCny() == null : this.getAmountCny().equals(other.getAmountCny()))
            && (this.getAmountUsd() == null ? other.getAmountUsd() == null : this.getAmountUsd().equals(other.getAmountUsd()))
            && (this.getGoodsQuantity() == null ? other.getGoodsQuantity() == null : this.getGoodsQuantity().equals(other.getGoodsQuantity()))
            && (this.getNumericFields() == null ? other.getNumericFields() == null : this.getNumericFields().equals(other.getNumericFields()))
            && (this.getParentId() == null ? other.getParentId() == null : this.getParentId().equals(other.getParentId()))
            && (this.getLevel() == null ? other.getLevel() == null : this.getLevel().equals(other.getLevel()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getQueryConditionId() == null) ? 0 : getQueryConditionId().hashCode());
        result = prime * result + ((getDimensionValues() == null) ? 0 : getDimensionValues().hashCode());
        result = prime * result + ((getDeclareCount() == null) ? 0 : getDeclareCount().hashCode());
        result = prime * result + ((getRecordCount() == null) ? 0 : getRecordCount().hashCode());
        result = prime * result + ((getAmountCny() == null) ? 0 : getAmountCny().hashCode());
        result = prime * result + ((getAmountUsd() == null) ? 0 : getAmountUsd().hashCode());
        result = prime * result + ((getGoodsQuantity() == null) ? 0 : getGoodsQuantity().hashCode());
        result = prime * result + ((getNumericFields() == null) ? 0 : getNumericFields().hashCode());
        result = prime * result + ((getParentId() == null) ? 0 : getParentId().hashCode());
        result = prime * result + ((getLevel() == null) ? 0 : getLevel().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", queryConditionId=").append(queryConditionId);
        sb.append(", dimensionValues=").append(dimensionValues);
        sb.append(", declareCount=").append(declareCount);
        sb.append(", recordCount=").append(recordCount);
        sb.append(", amountCny=").append(amountCny);
        sb.append(", amountUsd=").append(amountUsd);
        sb.append(", goodsQuantity=").append(goodsQuantity);
        sb.append(", numericFields=").append(numericFields);
        sb.append(", parentId=").append(parentId);
        sb.append(", level=").append(level);
        sb.append(", createTime=").append(createTime);
        sb.append("]");
        return sb.toString();
    }
}